<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OptProjectExpenses.aspx.cs" Inherits="OptProjectExpenses"
    Culture="auto:en-US" UICulture="auto" meta:resourcekey="PageResource1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Expenditure</title>
    <link href="Ip.css" rel="stylesheet" type="text/css" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
		<asp:ImageButton ID="ibProjectInfo" runat="server" ImageUrl="~/Images/p_ProjInfo-en-us.gif" meta:resourcekey="ibProjectInfoResource1" OnClick="ibProjectInfo_Click" />
		<asp:ImageButton ID="ibViewDoc" runat="server" ImageUrl="~/Images/p_ViewDoc-en-us.gif" meta:resourcekey="ibViewDocResource1" OnClick="ibViewDoc_Click" />
		<asp:ImageButton ID="ibProjectHeaderInfo" runat="server" ImageUrl="~/Images/p_AppProc-en-us.gif" meta:resourcekey="ibProjectHeaderInfoResource1" OnClick="ibProjectHeaderInfo_Click" />
		<asp:ImageButton ID="ibExpenditure" runat="server" ImageUrl="~/Images/p_Finance-en-us.gif" meta:resourcekey="ibExpenditureResource1" OnClick="ibExpenditure_Click" />
		<asp:TextBox ID="txtProjectGroupID" runat="server" Visible="False" Width="41px"></asp:TextBox>
		<asp:TextBox ID="txtProjectCode" runat="server" Visible="False" Width="41px"></asp:TextBox>
		<asp:TextBox ID="txtType" runat="server" Visible="False" Width="41px"></asp:TextBox>
		<asp:ScriptManager ID="ScriptManager1" runat="server"/>
		<div>
			<table width="700px">
				<tr>
					<td align="Center">
						<asp:Label ID="lblError" runat="server" Text="[ErrorMessage]" CssClass="error" Visible="False"
							meta:resourcekey="lblErrorResource1"></asp:Label>
					</td>
				</tr>
			</table>
			<asp:HiddenField ID="hidIsDelete" runat="server" Value="False" />
			<asp:HiddenField ID="hidExpensesIsDelete" runat="server" Value="True" />
			<asp:ObjectDataSource ID="ODSExpenditure" runat="server" OldValuesParameterFormatString="original_{0}"
				SelectMethod="GetIsDeleteExpensesByProjectCode" TypeName="IPTableAdapters.ProjectExpensesTableAdapter"
				DeleteMethod="Delete" InsertMethod="Insert" UpdateMethod="Update">
				<SelectParameters>
					<asp:QueryStringParameter Name="ProjectCode" QueryStringField="pc" Type="String"
						DefaultValue="x" />
					<asp:SessionParameter DefaultValue="False" Name="SuperUser" SessionField="SuperUser"
						Type="String" />
					<asp:SessionParameter DefaultValue="" Name="OwnerGroupID" SessionField="OwnerGroupID"
						Type="String" />
					<asp:ControlParameter ControlID="hidIsDelete" DefaultValue="" Name="IsDelete" PropertyName="Value"
						Type="String" />
				</SelectParameters>
				<DeleteParameters>
					<asp:Parameter Name="IsDelete" Type="Boolean" />
					<asp:Parameter Name="DeleteBy" Type="String" />
					<asp:Parameter Name="DeleteIP" Type="String" />
					<asp:Parameter Name="Original_ProjectCode" Type="String" />
					<asp:Parameter Name="Original_InvoiceNumber" Type="String" />
				</DeleteParameters>
				<UpdateParameters>
					<asp:Parameter Name="ReferenceDate" Type="DateTime" />
					<asp:Parameter Name="ChargeFrom" Type="String" />
					<asp:Parameter Name="Description" Type="String" />
					<asp:Parameter Name="ServiceCharge" Type="Decimal" />
					<asp:Parameter Name="UpdateBy" Type="String" />
					<asp:Parameter Name="Original_ProjectCode" Type="String" />
					<asp:Parameter Name="UpdateIP" Type="String" />
					<asp:Parameter Name="Original_InvoiceNumber" Type="String" />
				</UpdateParameters>
				<InsertParameters>
					<asp:Parameter Name="ProjectCode" Type="String" />
					<asp:Parameter Name="InvoiceNumber" Type="String" />
					<asp:Parameter Name="ReferenceDate" Type="DateTime" />
					<asp:Parameter Name="ChargeFrom" Type="String" />
					<asp:Parameter Name="Description" Type="String" />
					<asp:Parameter Name="ServiceCharge" Type="Decimal" />
					<asp:Parameter Name="CreateBy" Type="String" />
					<asp:Parameter Name="UpdateBy" Type="String" />
					<asp:Parameter Name="OwnerGroupID" Type="String" />
					<asp:Parameter Name="CreateIP" Type="String" />
				</InsertParameters>
			</asp:ObjectDataSource>
			<asp:ObjectDataSource ID="ODSExpenditureDelete" runat="server" OldValuesParameterFormatString="original_{0}"
				SelectMethod="GetIsDeleteExpensesByProjectCode" TypeName="IPTableAdapters.ProjectExpensesTableAdapter">
				<SelectParameters>
					<asp:QueryStringParameter Name="ProjectCode" QueryStringField="pc" Type="String"
						DefaultValue="x" />
					<asp:SessionParameter DefaultValue="False" Name="SuperUser" SessionField="SuperUser"
						Type="String" />
					<asp:SessionParameter DefaultValue="" Name="OwnerGroupID" SessionField="OwnerGroupID"
						Type="String" />
					<asp:ControlParameter ControlID="hidExpensesIsDelete" DefaultValue="" Name="IsDelete"
						PropertyName="Value" Type="String" />
				</SelectParameters>
			</asp:ObjectDataSource>
			<asp:Panel ID="Panel1" runat="server" Width="680px" meta:resourcekey="Panel1Resource1">
					<fieldset style="text-align: center">
						<legend>
							<asp:Label ID="lblNewInvoice" runat="server" Font-Bold="True" Text="New Invoice" meta:resourcekey="lblNewInvoice"/>
						</legend>
						<table width="680px">
							<tr>
								<td style="width: 20%; vertical-align: top; text-align: right;">
									<asp:Label ID="lblInvoiceNo" runat="server" Text="Invoice No." meta:resourcekey='lblInvoiceNo'
										Width="100%"></asp:Label>
								</td>
								<td style="vertical-align: top; text-align: left;">
									<asp:TextBox ID="txtInvoiceNo" runat="server" ReadOnly="True" CssClass="required"
										meta:resourcekey="txtInvoiceNoResource1" MaxLength="30" Width="230px"></asp:TextBox>
									<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtInvoiceNo"
										Display="Dynamic" ErrorMessage="Invoice No. is required." meta:resourcekey="RequiredFieldValidator1Resource1"
										ValidationGroup="ExpenseGroup"></asp:RequiredFieldValidator>
								</td>
							</tr>
							<tr>
								<td style="width: 20%; vertical-align: top; text-align: right;">
									<asp:Label ID="lblReferenceDate" runat="server" Text="Reference Date" meta:resourcekey='lblReferenceDate'
										Width="100%"></asp:Label>
								</td>
								<td style="vertical-align: top; text-align: left;">
									<asp:TextBox ID="txtReferenceDate" runat="server" ReadOnly="True" meta:resourcekey="txtReferenceDateResource1"
										CssClass="required"></asp:TextBox>
									<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtReferenceDate"
										Display="Dynamic" ErrorMessage="Reference Date  is required." meta:resourcekey="RequiredFieldValidator1Resource1"
										ValidationGroup="ExpenseGroup"></asp:RequiredFieldValidator>
									<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtReferenceDate"
										Enabled="True" Format="dd/MM/yyyy">
									</cc1:CalendarExtender>
								</td>
							</tr>
							<tr>
								<td style="width: 20%; vertical-align: top; text-align: right;">
									<asp:Label ID="lblChargeFrom" runat="server" Text="Charge From" meta:resourcekey='lblChargeFrom'
										Width="100%"></asp:Label>
								</td>
								<td style="vertical-align: top; text-align: left;">
									<asp:TextBox ID="txtChargeFrom" runat="server" ReadOnly="True" CssClass="required"
										meta:resourcekey="txtChargeFromResource1" MaxLength="30" Width="230px"></asp:TextBox>
									<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtChargeFrom"
										Display="Dynamic" ErrorMessage="Charge From is required." meta:resourcekey="RequiredFieldValidator2Resource1"
										ValidationGroup="ExpenseGroup"></asp:RequiredFieldValidator>
								</td>
							</tr>
							<tr>
								<td style="width: 20%; vertical-align: top; text-align: right;">
									<asp:Label ID="lblDescription" runat="server" Text="Description" meta:resourcekey='lblDescription'
										Width="100%"></asp:Label>
								</td>
								<td style="vertical-align: top; text-align: left;">
									<asp:TextBox ID="txtDescription" runat="server" Width="400px" ReadOnly="True" meta:resourcekey="txtDescriptionResource1"
										MaxLength="100"></asp:TextBox>
								</td>
							</tr>
							<tr>
								<td style="width: 20%; vertical-align: top; text-align: right;">
									<asp:Label ID="lblServiceChage" runat="server" Text="Service Charge (HK$)" meta:resourcekey="lblServiceChage" Width="100%"/>
								</td>
								<td style="vertical-align: top; text-align: left;">
									<asp:TextBox ID="txtServiceCharge" runat="server" ReadOnly="True" CssClass="required"
										meta:resourcekey="txtServiceChargeResource1" ValidationGroup="MKE" Width="194px"></asp:TextBox>
									<cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="txtServiceCharge"
										Mask="9,999,999.99" MaskType="Number" InputDirection="RightToLeft" AcceptNegative="Left"
										DisplayMoney="Left" Enabled="True" CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder=""
										CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder="" CultureThousandsPlaceholder=""
										CultureTimePlaceholder="" />
									<cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlExtender="MaskedEditExtender1"
										ControlToValidate="txtServiceCharge" IsValidEmpty="False" EmptyValueMessage="Service Charge is a required"
										InvalidValueMessage="Service Charge is invalid" MinimumValueMessage="Service Charge &lt; 1"
										MinimumValue="1" Display="Dynamic" ValidationGroup="ExpenseGroup" ErrorMessage="MaskedEditValidator1"
										meta:resourcekey="MaskedEditValidator1Resource1" Enabled="False" />
								</td>
							</tr>
							<tr>
								<td style="width: 80%; text-align: center;" colspan="2">
									<asp:Button ID="btnNew" runat="server" Text="New" OnClick="btnAddExpenditure_Click" meta:resourcekey="btnAddExpenditure" CssClass="submit" CausesValidation="False" />
									<asp:Button ID="btnModify" runat="server" Text="Edit" OnClick="btnModifyExpenditure_Click" meta:resourcekey="btnModifyExpenditure" CssClass="submit" CausesValidation="False" />
									<asp:Button ID="btnSave" runat="server" CssClass="submit" OnClick="btnSaveExpenditure_Click" meta:resourcekey="btnSaveExpenditure" Text="Save" ValidationGroup="ExpenseGroup" />
									<asp:Button ID="btnDelete" runat="server" CssClass="submit" OnClick="btnDelete_Click" Text="Delete" meta:resourcekey="btnDeleteResource1" />
									<asp:Button ID="btnRestore" runat="server" Text="Restore" meta:resourcekey='btnRestore' OnClick="btnRestore_Click" CssClass="submit" CausesValidation="False" />
									<asp:Button ID="btnCancel" runat="server" CssClass="reset" OnClick="btnCancelExpenditure_Click" meta:resourcekey="btnCancelExpenditure" Text="Cancel" CausesValidation="False" />&nbsp;
									<asp:CheckBox ID="chkForOperation" runat="server" Visible="False" meta:resourcekey="chkForOperationResource1" />
									<asp:CheckBox ID="CheckBox1" runat="server" Height="2px" Visible="False" Width="121px" meta:resourcekey="CheckBox1Resource1" />
									<asp:CheckBox ID="cbForUpdate" runat="server" CssClass="hidden" meta:resourcekey="cbForUpdateResource1" />
								</td>
							</tr>
						</table>
					</fieldset>
			</asp:Panel>
			<asp:Panel ID="GridExpenditurePanel" runat="server" Height="400px" Width="700px" ScrollBars="Auto" meta:resourcekey="GridExpenditurePanelResource1">
				<fieldset>
					<legend>
						<asp:Label ID="lblActive" runat="server" Text="Active Invoice" meta:resourcekey="lblActiveResource1"></asp:Label>
					</legend>
					<asp:GridView CssClass="Grid" ID="GridViewExpenditure" runat="server" 
							AutoGenerateColumns="False"
							BackColor="#DEBA84" 
							BorderColor="#660000" 
							BorderStyle="Solid" 
							BorderWidth="1px"
							CellPadding="0" 
							CellSpacing="0" 
							DataKeyNames="ProjectCode,InvoiceNumber,ReferenceDate,ChargeFrom,Description,ServiceCharge,IsDelete"
							DataSourceID="ODSExpenditure" 
							Height="1px" 
							Width="680px" 
							ShowFooter="True"
							OnRowDataBound="ComputeSum" 
							OnSelectedIndexChanged="GridViewExpenditure_SelectedIndexChanged">
						<Columns>
							<asp:BoundField DataField="ProjectCode" HeaderText="Project Code" ReadOnly="True" SortExpression="ProjectCode" meta:resourcekey="BoundFieldResource12" />
							<asp:ButtonField CommandName="Select" DataTextField="ProjectCode" HeaderText="Project Code" SortExpression="ProjectCode" Visible="False"/>
							<asp:BoundField DataField="InvoiceNumber" HeaderText="Invoice Number" ReadOnly="True"
								SortExpression="InvoiceNumber" meta:resourcekey="BoundFieldResource13" />
							<asp:BoundField DataField="ReferenceDate" HeaderText="Reference Date" SortExpression="ReferenceDate"
								DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="False" meta:resourcekey="BoundFieldResource14">
								<ItemStyle Wrap="False" />
								<HeaderStyle CssClass="GridHeaderStyle" Wrap="False" />
							</asp:BoundField>
							<asp:BoundField DataField="ChargeFrom" HeaderText="Charge From" SortExpression="ChargeFrom"
								meta:resourcekey="BoundFieldResource15" />
							<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description"
								meta:resourcekey="BoundFieldResource16" />
							<asp:BoundField DataField="ServiceCharge" HeaderText="Service Charge (HK$)" SortExpression="ServiceCharge"
								DataFormatString="{0:C}" HtmlEncode="False" meta:resourcekey="BoundFieldResource17">
								<ItemStyle HorizontalAlign="Right" />
							</asp:BoundField>
							<asp:BoundField DataField="UpdateIP" HeaderText="IP Address" ItemStyle-HorizontalAlign="left"
								meta:resourcekey="BoundFieldResourceUpdateIP" />
							<asp:BoundField DataField="UpdateBy" HeaderText="Updated By" ItemStyle-HorizontalAlign="left"
								meta:resourcekey="BoundFieldResourceUpdateBy" />
							<asp:BoundField DataField="UpdateDate" HeaderText="Last Update Date" ItemStyle-HorizontalAlign="left"
								meta:resourcekey="BoundFieldResourceUpdateDate" />
							<asp:TemplateField HeaderText="Edit" meta:resourcekey="BoundFieldResourceSelect">
								<ItemTemplate>
									<asp:ImageButton ID="lbtnSelect" CommandName="Select" ImageUrl="Images/icon-edit.gif" runat="server"/>
								</ItemTemplate>
								<ItemStyle HorizontalAlign="Center" />
							</asp:TemplateField>
						</Columns>
						<HeaderStyle CssClass="GridHeaderStyle" ForeColor="White" />
						<RowStyle CssClass="GridRowStyle" />
						<AlternatingRowStyle CssClass="GridAltRowStyle" />
						<SelectedRowStyle CssClass="GridSelectedRowStyle" />
						<PagerStyle CssClass="GridPagerStyle" ForeColor="White" />
						<FooterStyle CssClass="GridFooterStyle" />
					</asp:GridView>
				</fieldset>
				<asp:Panel id="pnlProjectDel" runat="server">
					<fieldset>
						<legend>
							<asp:Label ID="lblDeleted" runat="server" Text="Deleted Invoice" meta:resourcekey="lblDeletedResource1"></asp:Label>
						</legend>
						<asp:GridView CssClass="Grid" ID="gvExpensesDeleteList" runat="server" 
								AutoGenerateColumns="False"
								BackColor="#DEBA84" 
								BorderColor="#660000" 
								BorderStyle="Solid" 
								BorderWidth="1px"
								CellPadding="0" 
								CellSpacing="0" 
								DataKeyNames="ProjectCode,InvoiceNumber,ReferenceDate,ChargeFrom,Description,ServiceCharge,IsDelete"
								DataSourceID="ODSExpenditureDelete" 
								Height="1px" 
								Width="680px" 
								OnSelectedIndexChanged="gvExpensesDeleteList_SelectedIndexChanged"
								ShowFooter="True" 
								OnRowCommand="gvExpensesDeleteList_RowCommand"
								OnRowDataBound="gvExpensesDeleteList_RowDataBound">
							<Columns>
								<asp:BoundField DataField="ProjectCode" HeaderText="Project Code" ReadOnly="True"
									SortExpression="ProjectCode" meta:resourcekey="BoundFieldResource12" />
								<asp:ButtonField CommandName="Select" DataTextField="ProjectCode" HeaderText="Project Code" SortExpression="ProjectCode" Visible="False"/>
								<asp:BoundField DataField="InvoiceNumber" HeaderText="Invoice Number" ReadOnly="True"
									SortExpression="InvoiceNumber" meta:resourcekey="BoundFieldResource13" />
								<asp:BoundField DataField="ReferenceDate" HeaderText="Reference Date" SortExpression="ReferenceDate"
									DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="False" meta:resourcekey="BoundFieldResource14">
									<ItemStyle Wrap="False" />
									<HeaderStyle CssClass="GridHeaderStyle" Wrap="False" />
								</asp:BoundField>
								<asp:BoundField DataField="ChargeFrom" HeaderText="Charge From" SortExpression="ChargeFrom"
									meta:resourcekey="BoundFieldResource15" />
								<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description"
									meta:resourcekey="BoundFieldResource16" />
								<asp:BoundField DataField="ServiceCharge" HeaderText="Service Charge (HK$)" SortExpression="ServiceCharge"
									DataFormatString="{0:C}" HtmlEncode="False" meta:resourcekey="BoundFieldResource17">
									<ItemStyle HorizontalAlign="Right" />
								</asp:BoundField>
								<asp:BoundField DataField="DeleteIP" HeaderText="IP Address" ItemStyle-HorizontalAlign="left"
									meta:resourcekey="BoundFieldResourceDeleteIP" />
								<asp:BoundField DataField="DeleteBy" HeaderText="Deleted By" ItemStyle-HorizontalAlign="left"
									meta:resourcekey="BoundFieldResourceDeleteBy" />
								<asp:BoundField DataField="DeleteDate" HeaderText="Delete Date" ItemStyle-HorizontalAlign="left"
									meta:resourcekey="BoundFieldResourceDeleteDate" />
								<asp:TemplateField HeaderText="Restore" meta:resourcekey="lbtnRestoreResource">
									<ItemTemplate>
										<asp:Label ID="lblIsDelete" runat="server" Text='<%# Eval("IsDelete") %>' Visible="false"></asp:Label>
										<asp:ImageButton ID="lbtnRestore" CommandName="Restore" ImageUrl="Images/icon-restore.jpg" runat="server"/>
									</ItemTemplate>
									<ItemStyle HorizontalAlign="Center" />
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Trash" meta:resourcekey="BoundFieldResourceFroceDelete">
									<ItemTemplate>
										<asp:ImageButton ID="lbtnFroceDelete" CommandName="ForceDelete" ImageUrl="Images/icon-trash.gif" runat="server"/>
									</ItemTemplate>
									<ItemStyle HorizontalAlign="Center" />
								</asp:TemplateField>
							</Columns>
							<HeaderStyle CssClass="GridHeaderStyle" ForeColor="White" />
							<RowStyle CssClass="GridRowStyle" />
							<AlternatingRowStyle CssClass="GridAltRowStyle" />
							<SelectedRowStyle CssClass="GridSelectedRowStyle" />
							<PagerStyle CssClass="GridPagerStyle" ForeColor="White" />
							<FooterStyle CssClass="GridFooterStyle" />
						</asp:GridView>
					</fieldset>
				</asp:Panel>
			</asp:Panel>
		</div>
    </form>
</body>
</html>
